.image-viewer {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #0d1117;
  overflow: hidden;
}

.viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: #21262d;
  border-bottom: 1px solid #30363d;
  flex-shrink: 0;
}

.viewer-header h3 {
  margin: 0;
  color: #f0f6fc;
  font-size: 16px;
  font-weight: 600;
}

.frame-counter {
  font-size: 12px;
  color: #8b949e;
  font-weight: 500;
  background: #30363d;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #484f58;
}

/* Frame slider styles - 底部overlay样式 */
.frame-slider-overlay {
  display: none;
}

.frame-slider-main {
  width: 100%;
  height: 8px;
  background: transparent;
  border-radius: 4px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  position: relative;
  margin-bottom: 8px;
}

.frame-slider-main::-webkit-slider-track {
  width: 100%;
  height: 8px;
  background: rgba(48, 54, 61, 0.8);
  border-radius: 4px;
  border: 1px solid rgba(72, 79, 88, 0.5);
}

.frame-slider-main::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: #58a6ff;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 3px solid #21262d;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.frame-slider-main::-webkit-slider-thumb:hover {
  background: #79c0ff;
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(88, 166, 255, 0.3);
}

.frame-slider-main::-moz-range-track {
  width: 100%;
  height: 8px;
  background: rgba(48, 54, 61, 0.8);
  border-radius: 4px;
  border: 1px solid rgba(72, 79, 88, 0.5);
}

.frame-slider-main::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: #58a6ff;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid #21262d;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.frame-slider-main::-moz-range-thumb:hover {
  background: #79c0ff;
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(88, 166, 255, 0.3);
}

.slider-progress {
  position: absolute;
  bottom: 12px;
  left: 20px;
  height: 8px;
  background: linear-gradient(to right, #58a6ff, #79c0ff);
  border-radius: 4px;
  pointer-events: none;
  transition: width 0.1s ease;
  border: 1px solid rgba(88, 166, 255, 0.3);
}

.slider-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: #f0f6fc;
  font-weight: 500;
}

.slider-info span {
  background: rgba(33, 38, 45, 0.8);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid rgba(88, 166, 255, 0.2);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

/* 移除旧的slider样式 */
.frame-slider-container {
  display: none;
}

.frame-slider {
  display: none;
}

.slider-labels {
  display: none;
}

.viewer-content {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
}

.cornerstone-element {
  width: 100%;
  height: 100%;
  position: relative;
  background: #000;
  cursor: crosshair;
}

.cornerstone-element canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  margin: auto;
}

.simple-viewer-container {
  flex: 1;
  position: relative;
  background: #000;
  overflow: hidden;
  min-height: 300px;
  min-width: 400px;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.simple-viewer-container canvas {
  max-width: 100%;
  max-height: 100%;
  border: 1px solid #30363d;
  border-radius: 4px;
  display: block;
}

.viewer-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 16px;
  background: #21262d;
  border-top: 1px solid #30363d;
  flex-shrink: 0;
  gap: 16px;
  flex-wrap: wrap;
}

.viewport-info,
.image-info {
  display: flex;
  gap: 12px;
  font-size: 10px;
  color: #8b949e;
}

.viewport-info span,
.image-info span {
  background: #30363d;
  padding: 3px 6px;
  border-radius: 3px;
  border: 1px solid #484f58;
  white-space: nowrap;
}

.viewport-info span:first-child {
  color: #58a6ff;
  font-weight: 600;
}

/* 工具指示器 */
.tool-indicator {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(33, 38, 45, 0.9);
  color: #c9d1d9;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid #30363d;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

/* 加载状态 */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(13, 17, 23, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #30363d;
  border-top: 3px solid #58a6ff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* 错误覆盖层 */
.error-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(248, 81, 73, 0.9);
  color: #fff;
  padding: 16px 24px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  z-index: 1000;
}

.error-message {
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}

/* 伪彩色条 */
.colorbar {
  width: 60px;
  display: flex;
  flex-direction: column;
  background: #21262d;
  border-left: 1px solid #30363d;
  flex-shrink: 0;
}

.colorbar-gradient {
  flex: 1;
  background: linear-gradient(to top, 
    #000080 0%,    /* 深蓝 */
    #0000ff 12.5%, /* 蓝 */
    #00ffff 25%,   /* 青 */
    #00ff00 37.5%, /* 绿 */
    #ffff00 50%,   /* 黄 */
    #ff8000 62.5%, /* 橙 */
    #ff0000 75%,   /* 红 */
    #800000 100%   /* 深红 */
  );
  margin: 10px;
  border-radius: 4px;
  border: 1px solid #30363d;
}

.colorbar-gradient.hot {
  background: linear-gradient(to top,
    #000000 0%,    /* 黑 */
    #800000 33%,   /* 深红 */
    #ff0000 50%,   /* 红 */
    #ff8000 67%,   /* 橙 */
    #ffff00 83%,   /* 黄 */
    #ffffff 100%   /* 白 */
  );
}

.colorbar-labels {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 60px;
  margin: 0 10px 10px;
  font-size: 10px;
  color: #8b949e;
}

.colorbar-labels span {
  text-align: center;
  background: #30363d;
  padding: 2px 4px;
  border-radius: 2px;
  border: 1px solid #484f58;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .viewer-header {
    padding: 8px 16px;
    flex-direction: column;
    gap: 8px;
  }
  
  .viewer-header h3 {
    font-size: 14px;
  }
  
  .tdc-header-button {
    padding: 5px 10px; /* 从6px 12px调整为5px 10px */
    font-size: 12px; /* 从13px减少到12px */
    gap: 4px; /* 从6px减少到4px */
  }
  
  .tdc-icon {
    font-size: 14px;
  }
  
  .tdc-status {
    font-size: 10px;
    padding: 1px 4px;
  }
  
  .frame-counter {
    font-size: 11px;
    padding: 4px 8px;
    min-width: 70px;
  }
  
  .frame-slider-bottom {
    padding: 8px 16px;
  }
  
  .frame-slider-main {
    height: 10px;
  }
  
  .frame-slider-main::-webkit-slider-thumb {
    width: 22px;
    height: 22px;
  }
  
  .frame-slider-main::-moz-range-thumb {
    width: 22px;
    height: 22px;
  }
  
  .slider-info {
    font-size: 10px;
  }
  
  .simple-viewer-container {
    min-height: 300px;
  }
}

/* 禁用状态的按钮样式 */
.mode-toggle:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.mode-toggle:disabled:hover {
  background: var(--surface-color);
  transform: none;
}

.simple-viewer-container {
  min-height: 300px;
}

.colorbar {
  width: 50px;
}

.colorbar-labels {
  font-size: 9px;
  height: 50px;
}

.viewer-info {
  padding: 6px 16px;
  gap: 12px;
}

.viewport-info,
.image-info {
  gap: 8px;
  font-size: 10px;
}

.viewport-info span,
.image-info span {
  padding: 3px 6px;
}

/* Frame slider styles - 独立底部组件 */
.frame-slider-bottom {
  background: #21262d;
  border-top: 1px solid #30363d;
  padding: 12px 20px;
  flex-shrink: 0;
}

.slider-container {
  display: flex;
  align-items: center;
  gap: 16px;
}

.slider-track {
  flex: 1;
  position: relative;
  height: 20px;
  display: flex;
  align-items: center;
}

.frame-slider-main {
  width: 100%;
  height: 8px;
  background: transparent;
  border-radius: 4px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  position: relative;
  z-index: 2;
}

.frame-slider-main::-webkit-slider-track {
  width: 100%;
  height: 8px;
  background: #30363d;
  border-radius: 4px;
  border: 1px solid #484f58;
}

.frame-slider-main::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: #58a6ff;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 3px solid #21262d;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.frame-slider-main::-webkit-slider-thumb:hover {
  background: #79c0ff;
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(88, 166, 255, 0.3);
}

.frame-slider-main::-moz-range-track {
  width: 100%;
  height: 8px;
  background: #30363d;
  border-radius: 4px;
  border: 1px solid #484f58;
}

.frame-slider-main::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: #58a6ff;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid #21262d;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.frame-slider-main::-moz-range-thumb:hover {
  background: #79c0ff;
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(88, 166, 255, 0.3);
}

.slider-progress {
  position: absolute;
  top: 50%;
  left: 0;
  height: 8px;
  background: linear-gradient(to right, #58a6ff, #79c0ff);
  border-radius: 4px;
  pointer-events: none;
  transition: width 0.1s ease;
  border: 1px solid rgba(88, 166, 255, 0.3);
  transform: translateY(-50%);
  z-index: 1;
}

.frame-counter {
  font-size: 12px;
  color: #f0f6fc;
  font-weight: 500;
  background: #30363d;
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid #484f58;
  white-space: nowrap;
  min-width: 80px;
  text-align: center;
}

.canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 100%;
  min-height: 0; /* 重要：允许flex收缩 */
}

.image-canvas,
.overlay-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  max-width: 100%; /* 防止canvas超出容器 */
  max-height: 100%; /* 防止canvas超出容器 */
}

/* Header Buttons Container */
.header-buttons {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* TDC Header Button 样式 */
.tdc-header-button {
  display: flex;
  align-items: center;
  gap: 4px; /* 从8px减少到4px */
  padding: 4px 8px; /* 从8px 16px减少到4px 8px */
  background: linear-gradient(135deg, #6f42c1, #8957e5);
  border: 1px solid #8957e5;
  border-radius: 4px; /* 从6px减少到4px */
  color: #f0f6fc;
  font-size: 12px; /* 从14px减少到12px */
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  outline: none;
}

.tdc-header-button:hover {
  background: linear-gradient(135deg, #8957e5, #a670f0);
  border-color: #a670f0;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(111, 66, 193, 0.3);
}

.tdc-header-button.active {
  background: linear-gradient(135deg, #238636, #2ea043);
  border-color: #46954a;
  box-shadow: 0 0 0 2px rgba(35, 134, 54, 0.3);
}

.tdc-header-button.active:hover {
  background: linear-gradient(135deg, #2ea043, #46954a);
  border-color: #56ab5a;
}

.tdc-icon {
  font-size: 14px; /* 从16px减少到14px */
  line-height: 1;
}

.tdc-text {
  font-weight: 500;
}

.tdc-status {
  background: rgba(240, 246, 252, 0.2);
  color: #f0f6fc;
  padding: 1px 4px; /* 从2px 6px减少到1px 4px */
  border-radius: 6px; /* 从8px减少到6px */
  font-size: 10px; /* 从11px减少到10px */
  font-weight: 500;
}

/* Vessel Header Button 样式 */
.vessel-header-button {
  display: flex;
  align-items: center;
  gap: 4px; /* 从8px减少到4px */
  padding: 4px 8px; /* 从8px 16px减少到4px 8px */
  background: linear-gradient(135deg, #d73527, #e94e3d);
  border: 1px solid #e94e3d;
  border-radius: 4px; /* 从6px减少到4px */
  color: #f0f6fc;
  font-size: 12px; /* 从14px减少到12px */
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  outline: none;
}

.vessel-header-button:hover {
  background: linear-gradient(135deg, #e94e3d, #f56565);
  border-color: #f56565;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(215, 53, 39, 0.3);
}

.vessel-header-button.active {
  background: linear-gradient(135deg, #238636, #2ea043);
  border-color: #46954a;
  box-shadow: 0 0 0 2px rgba(35, 134, 54, 0.3);
}

.vessel-header-button.active:hover {
  background: linear-gradient(135deg, #2ea043, #46954a);
  border-color: #56ab5a;
}

.vessel-icon {
  font-size: 14px; /* 从16px减少到14px */
  line-height: 1;
}

.vessel-text {
  font-weight: 500;
}

.vessel-status {
  background: rgba(240, 246, 252, 0.2);
  color: #f0f6fc;
  padding: 2px 6px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 500;
}

/* TDC工具栏样式 */
.tdc-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: #21262d;
  border-bottom: 1px solid #30363d;
  flex-shrink: 0;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative; /* 为弹出框提供定位基准 */
}

.tool-btn {
  background: #30363d;
  border: 1px solid #484f58;
  color: #c9d1d9;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  outline: none;
}

.tool-btn:hover {
  background: #484f58;
  border-color: #6e7681;
  transform: translateY(-1px);
}

.tool-btn.active {
  background: #238636;
  border-color: #2ea043;
  color: #f0f6fc;
  box-shadow: 0 0 0 2px rgba(35, 134, 54, 0.3);
}

.tool-btn.active:hover {
  background: #2ea043;
  border-color: #46954a;
}

.tool-btn.danger {
  background: #da3633;
  border-color: #f85149;
  color: #f0f6fc;
}

.tool-btn.danger:hover {
  background: #f85149;
  border-color: #ff7b72;
}

.tool-separator {
  color: #484f58;
  font-weight: 300;
}

/* 帮助按钮样式 */
.help-btn {
  background: #f7931e;
  border: 1px solid #fb8500;
  color: #fff;
  padding: 6px 8px;
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  position: relative;
}

.help-btn:hover {
  background: #fb8500;
  border-color: #ffb703;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(247, 147, 30, 0.3);
}

/* 操作说明弹出框 */
.instructions-popup {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  margin-top: 8px;
  min-width: 280px;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.instructions-content {
  padding: 16px;
}

.instructions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #30363d;
}

.instructions-header span {
  font-size: 14px;
  font-weight: 600;
  color: #f0f6fc;
}

.close-btn {
  background: transparent;
  border: none;
  color: #8b949e;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
  line-height: 1;
}

.close-btn:hover {
  background: #30363d;
  color: #f0f6fc;
}

.instructions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.instruction-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #0d1117;
  border: 1px solid #21262d;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.instruction-item:hover {
  background: #161b22;
  border-color: #30363d;
}

.instruction-item .key {
  font-size: 12px;
  font-weight: 600;
  color: #58a6ff;
  background: rgba(88, 166, 255, 0.1);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid rgba(88, 166, 255, 0.2);
  white-space: nowrap;
}

.instruction-item .action {
  font-size: 12px;
  color: #c9d1d9;
  text-align: right;
}

.marker-count-display {
  font-size: 12px;
  color: #58a6ff;
  font-weight: 500;
  background: rgba(88, 166, 255, 0.1);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid rgba(88, 166, 255, 0.2);
}

.frame-shortcuts {
  display: flex;
  gap: 6px;
  font-size: 10px;
  color: #6e7681;
}

.frame-shortcuts span {
  background: rgba(48, 54, 61, 0.4);
  padding: 2px 4px;
  border-radius: 2px;
  border: 1px solid rgba(72, 79, 88, 0.3);
}

/* 错误状态样式 */
.image-viewer-error {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: #0d1117;
  color: #c9d1d9;
}

.error-content {
  text-align: center;
  padding: 40px;
  background: #21262d;
  border-radius: 8px;
  border: 1px solid #30363d;
  max-width: 400px;
}

.error-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.error-message {
  font-size: 16px;
  margin-bottom: 20px;
  color: #f85149;
}

.retry-btn {
  background: #238636;
  border: 1px solid #2ea043;
  color: #f0f6fc;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.retry-btn:hover {
  background: #2ea043;
  border-color: #46954a;
  transform: translateY(-1px);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .tdc-toolbar {
    padding: 6px 12px;
    gap: 8px;
  }
  
  .toolbar-group {
    gap: 8px;
  }
  
  .tool-btn {
    padding: 4px 8px;
    font-size: 11px;
  }
  
  .instructions-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin-top: 0;
    max-width: 90vw;
    width: 300px;
  }
  
  .frame-shortcuts {
    display: none; /* 在移动设备上隐藏快捷键说明 */
  }
  
  .marker-count-display {
    font-size: 11px;
    padding: 3px 6px;
  }
}

/* 像素信息显示样式 */
.pixel-info {
  background: linear-gradient(135deg, #1f6feb, #0969da) !important;
  color: #f0f6fc !important;
  padding: 4px 8px !important;
  border-radius: 6px !important;
  font-weight: 600 !important;
  font-size: 12px !important;
  border: 1px solid #58a6ff !important;
  box-shadow: 0 2px 8px rgba(31, 111, 235, 0.3) !important;
  white-space: nowrap !important;
}

.pick-tip {
  background: rgba(46, 160, 67, 0.1) !important;
  color: #2ea043 !important;
  border: 1px solid rgba(46, 160, 67, 0.3) !important;
  padding: 3px 6px !important;
  border-radius: 4px !important;
  font-size: 11px !important;
  font-weight: 500 !important;
  white-space: nowrap !important;
}